<?php

$stats = array ('tomazek' => array('wr' => 54.7,
                                   'battle' => 12227,
                                   'frags' => 1.07,
                                   'dmg' => 994.29,
                                   'spot' => 1.53,
                                   'def' => 1.6,
                                   'cap' => 2.51,
                                   'tiers' => 6.54,
                    ),
                'Zoleem' => array('wr' => 54.54,
                                   'battle' => 9666,
                                   'frags' => 1.13,
                                   'dmg' => 1051.8,
                                   'spot' => 0.95,
                                   'def' => 1.74,
                                   'cap' => 2.35,
                                   'tiers' => 6.8,
                    ),
                'Oakley' => array('wr' => 50.23,
                                   'battle' => 5108,
                                   'frags' => 0.76,
                                   'dmg' => 302.53,
                                   'spot' => 0.85,
                                   'def' => 1.28,
                                   'cap' => 3.39,
                                   'tiers' => 4.29,
                    ),
                'Menerv' => array('wr' => 51.03,
                                   'battle' => 11104,
                                   'frags' => 0.75,
                                   'dmg' => 713.56,
                                   'spot' => 1.6,
                                   'def' => 0.76,
                                   'cap' => 1.39,
                                   'tiers' => 6.43,
                    ));

foreach ($stats as $player => $stat) {
    echo '<br>#  '.$player.'   #<br>';
    $wr = round(((185/(0.17+exp(($stat['wr']-35)*-0.134)))-500)*0.45,0);
    $frags = round((1240-1040/pow(min($stat['tiers'],6),0.164))*$stat['frags'],0);
    $dmg = round($stat['dmg']*530/(184*exp(0.24*$stat['tiers'])+130),0);
    $spot = round($stat['spot']*125*min($stat['tiers'],3)/3,0);
    $def = round(min($stat['def'],2.2)*100,0);
    $penalty = -((5-min($stat['tiers'],5))*125)/(1+EXP(($stat['tiers']-($stat['battle']/220)^(3/$stat['tiers']))*1.5)); 
    echo $wr;
    echo '-', $frags;
    echo '-', $dmg; 
    echo '-', $spot; 
    echo '-', $def; 
    echo '-', $penalty;
    echo ' = ' , $wr+$frags+$dmg+$spot+$def+$penalty;
}